package com.demo01;

import java.lang.reflect.Method;

public class Demo04 {
    public static void main(String[] args) throws NoSuchMethodException {
        //获取到Class对象
        Class c = Person.class;
        //获取方法
        //获取多个方法
        Method[] methods = c.getDeclaredMethods();
        //获取父类中的方法
//        Method[] methods = c.getMethods();
        for (Method method :
                methods) {
            System.out.println(method);
        }
        System.out.println("=================");
        //获取单个方法
        Method method1 = c.getMethod("method1", null);
        System.out.println(method1);

        Method method4 = c.getMethod("method4", String.class);
        System.out.println(method4);

        Method method5 = c.getDeclaredMethod("method5", null);
        System.out.println(method5);
    }
}
